package com.yhsoft.buyer.controller.Po;

import com.yhsoft.buyer.entity.BuyerUser;
import com.yhsoft.common.Enum.SexEnum;
import lombok.Data;

/**
 * @author yyyyyyyh
 * @since 2023-10-09
 */
@Data
public class WebUser implements User {

    /**
     * ID
     */
    private String id;

    /**
     * 微信unionID
     */
    private String unionId;

    /**
     * 微信openID
     */
    private String openId;

    /**
     * 性别
     */
    private SexEnum sex;

    /**
     * 微信名
     */
    private String name;

    /**
     * 真实姓名
     */
    private String realName;

    /**
     * 微信
     */
    private String wechat;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 国家
     */
    private String country;

    /**
     * 省份
     */
    private String province;

    /**
     * 城市
     */
    private String city;

    /**
     * 签名
     */
    private String signature;

    /**
     * 头像URL
     */
    private String avatarUrl;

    public static WebUser valueOf(BuyerUser tenantDO) {
        WebUser tenantUser = new WebUser();
        tenantUser.setId(tenantDO.getId());
        tenantUser.setOpenId(tenantDO.getOpenId());
        tenantUser.setUnionId(tenantDO.getUnionId());
        tenantUser.setSex(SexEnum.valueOf(tenantDO.getSex()));
        tenantUser.setName(tenantDO.getNickName());
        tenantUser.setRealName(tenantDO.getRealName());
        tenantUser.setWechat(tenantDO.getWechat());
        tenantUser.setPhone(tenantDO.getPhone());
        tenantUser.setCountry(tenantDO.getCountry());
        tenantUser.setProvince(tenantDO.getProvince());
        tenantUser.setCountry(tenantDO.getCity());
        tenantUser.setSignature(tenantDO.getSignature());
        tenantUser.setAvatarUrl(tenantDO.getAvatarUrl());
        return tenantUser;
    }

    @Override
    public String getUserId() {
        return this.id;
    }

    @Override
    public String getUserName() {
        return this.name;
    }
}
